home *** CD-ROM | disk | FTP | other *** search
- #! /usr/dt/bin/dtksh
- #
- # DtWsTest1
- #
- # Copyright 2000, Silicon Graphics, Inc.
- # ALL RIGHTS RESERVED
- #
- # UNPUBLISHED -- Rights reserved under the copyright laws of the United
- # States. Use of a copyright notice is precautionary only and does not
- # imply publication or disclosure.
- #
- # U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
- # in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
- # in similar or successor clauses in the FAR, or the DOD or NASA FAR
- # Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
- # 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
- #
- # THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
- # INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
- # DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
- # PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
- # GRAPHICS, INC.
- #
-
- ##########################################################################
- # (c) Copyright 1993, 1994 Hewlett-Packard Company
- # (c) Copyright 1993, 1994 International Business Machines Corp.
- # (c) Copyright 1993, 1994 Sun Microsystems, Inc.
- # (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
- # Novell, Inc.
- ##########################################################################
-
-
- #
- # This sample shell script demonstrates how to interact with the workspace
- # manager. It demonstrates the following capabilities:
- #
- # 1) How to query which workspaces the widgets currently reside it.
- # 2) How to set the current workspace.
- # 3) How to be notified when the current workspace changes.
- #
-
-
- integer wsCount
-
- # Pushbutton Callback: This function asks the workspace manager to change
- # to the workspace indicated by $1; $1 is an X atom
- # which identifies the new workspace. At some point
- # after our request to the workspace manager, the
- # workspace manager will activate our WsCB function,
- # letting us know that the change has actually taken
- # place.
- SetWorkspace()
- {
- echo
- if DtWsmSetCurrentWorkspace $TOPLEVEL $1; then
- echo "Changing to new workspace"
- else
- XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $1
- echo "Unable to Change to workspace " $NAME
- fi
- }
-
- # Workspace Changed Callback: This function is invoked whenever the workspace
- # manager changes workspaces. It will simply
- # query the 'name' of the new workspace, and
- # echo it outl
- WsCB()
- {
- DtWsmGetCurrentWorkspace $(XtDisplay "-" $TOPLEVEL) \
- $(XRootWindowOfScreen "-" $(XtScreen "-" $TOPLEVEL)) \
- NEW_ATOM
- XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $NEW_ATOM
- echo "Change to workspace complete " $NAME "("$NEW_ATOM")"
- }
-
- ######################### Create the Main UI #################################
-
- XtInitialize TOPLEVEL dtWsTest DtWsTest "$0" "$@"
- XtSetValues $TOPLEVEL allowShellResize:True
-
- XtCreateManagedWidget DA da XmDrawingArea $TOPLEVEL
- XtSetValues $DA height:200 width:200
-
- XtRealizeWidget $TOPLEVEL
- XSync $(XtDisplay "-" $TOPLEVEL) False
-
- XtCreateApplicationShell TOPLEVEL2 DtWsTesta TopLevelShell
-
- XtCreateManagedWidget RC rc XmRowColumn $TOPLEVEL2 \
- orientation:HORIZONTAL \
- packing:PACK_COLUMN
-
- # Get a list of all of the workspaces, and create a pushbutton for each one.
- # When a pushbutton is activated, it will ask the workspace manager to
- # change to the indicated workspace.
- oldIF=$IFS
- if DtWsmGetWorkspaceList $(XtDisplay "-" $TOPLEVEL) \
- $(XRootWindowOfScreen "-" $(XtScreen "-" $TOPLEVEL)) \
- WS_LIST;
- then
- IFS=,
- wsCount=0
- for item in $WS_LIST;
- do
- XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $item
- label="Set Current Workspace to "$NAME
- XtCreateManagedWidget ITEM $item XmPushButton $RC \
- labelString:$label
- XtAddCallback $ITEM activateCallback "SetWorkspace $item"
- wsCount=$wsCount+1
- done
- IFS=$oldIFS
- else
- echo "Unable to get workspace list"
- exit -1
- fi
-
- XtSetValues $RC numColumns:$wsCount
- XtRealizeWidget $TOPLEVEL2
- XSync $(XtDisplay "-" $TOPLEVEL) False
-
- # The following block queries the initial set of workspaces occupied by
- # this shell script; this list is printed out. Next, it will ask the
- # workspace manager to move the shell script windows into all workspaces.
- # Lastly, it will again ask the workspace manager for the list of
- # workspaces occupied by the shell script windows, and will again print
- # out the list.
- if DtWsmGetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL) \
- $(XtWindow "-" $TOPLEVEL) \
- CURRENT_WS_LIST ;
- then
- echo "Initial workspaces occupied:"
- for item in $CURRENT_WS_LIST;
- do
- XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $item
- echo " "$NAME
- done
-
- DtWsmGetWorkspaceList $(XtDisplay "-" $TOPLEVEL) \
- $(XRootWindowOfScreen "-" $(XtScreen "-" $TOPLEVEL)) \
- WS_LIST
-
- DtWsmSetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL) \
- $(XtWindow "-" $TOPLEVEL) \
- $WS_LIST
-
- DtWsmSetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL2) \
- $(XtWindow "-" $TOPLEVEL2) \
- $WS_LIST
- else
- echo "Unable to get current list of occupied workspaces"
- echo -2
- fi
-
- XSync $(XtDisplay "-" $TOPLEVEL) False
-
- # Print the new list of workspaces occupied
- DtWsmGetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL) \
- $(XtWindow "-" $TOPLEVEL) \
- CURRENT_WS_LIST
-
- echo "After modification, workspaces occupied:"
- IFS=,
- for item in $CURRENT_WS_LIST;
- do
- XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $item
- echo " "$NAME
- done
- IFS=$oldIFS
- echo ""
-
- # Add a callback to be notified whenever the workspace changes.
- DtWsmAddCurrentWorkspaceCallback HANDLE1 $TOPLEVEL WsCB
-
- XtMainLoop
-